//
//  QuestionCell.m
//  zhijian
//
//  Created by yiban on 2019/1/22.
//  Copyright © 2019 lcb. All rights reserved.
//

#import "QuestionCell.h"
@interface QuestionCell ()<TTTAttributedLabelDelegate>
@end
@implementation QuestionCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self setup];
    }
    return self;
}
-(void)dealloc
{
    self.lblTitle.delegate=nil;
    self.lblTitle=nil;
    self.userView=nil;
    self.operateView=nil;
}
-(void)setup{
    
    //
    self.userView =[UserCell new];
//    __weak typeof(self) weakSelf = self;
//    [self.userView setAvaterClickedOperation:^(YBMiaoNewsModel *tTModel) {
//        if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(didClickAvaterButtonInCell:indexPath:)]) {
//            [weakSelf.delegate didClickAvaterButtonInCell:tTModel indexPath:weakSelf.indexPath];
//        }
//    }];
    [self.contentView addSubview:self.userView];
    //
    
    self.lblTitle = [[BaseLabel alloc] initWithFrame:CGRectZero];
    self.lblTitle.font = [UIFont systemFontOfSize:16];
    self.lblTitle.numberOfLines = 0;
    self.lblTitle.textColor = UIColorOfHex(0x333333);
    self.lblTitle.linkAttributes = @{NSForegroundColorAttributeName : UIColorOfHex(0x00a5ed)};
    self.lblTitle.delegate= self;
    self.lblTitle.lineSpacing =5;
    [self.contentView addSubview:self.lblTitle];
    
    //
    self.operateView = [OperateCell new];
    __weak typeof(self) weakSelf = self;
    [self.operateView setCommentClickedOperation:^(BaseModel * _Nonnull bModel) {
        if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(didClickCommentCell:indexPath:)]) {
            [weakSelf.delegate didClickCommentCell:bModel indexPath:weakSelf.indexPath];
        }
    }];
    [self.contentView addSubview:self.operateView];
    //
    
    
}
- (void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url
{
    NSLog(@"notification = %@",  url.absoluteString);
//    if (self.delegate && [self.delegate respondsToSelector:@selector(didClickTopicInCell:indexPath:)]) {
//        NSString*string =[url.absoluteString stringByReplacingOccurrencesOfString:@"MiaoTopic://" withString:@""];
//        string =[string stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//
//        NSLog(@"replaceStr=%@",string);
//        [self.delegate didClickTopicInCell:string indexPath:self.sd_indexPath];
//    }
}
@end
